package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RosStep;
import com.ruoyi.system.service.IRosStepService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ros操作Controller
 * 
 * @author ruoyi
 * @date 2024-09-25
 */
@Controller
@RequestMapping("/system/step")
public class RosStepController extends BaseController
{
    private String prefix = "system/step";

    @Autowired
    private IRosStepService rosStepService;

    @RequiresPermissions("system:step:view")
    @GetMapping()
    public String step()
    {
        return prefix + "/step";
    }

    /**
     * 查询ros操作列表
     */
    @RequiresPermissions("system:step:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RosStep rosStep)
    {
        startPage();
        List<RosStep> list = rosStepService.selectRosStepList(rosStep);
        return getDataTable(list);
    }

    /**
     * 导出ros操作列表
     */
    @RequiresPermissions("system:step:export")
    @Log(title = "ros操作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RosStep rosStep)
    {
        List<RosStep> list = rosStepService.selectRosStepList(rosStep);
        ExcelUtil<RosStep> util = new ExcelUtil<RosStep>(RosStep.class);
        return util.exportExcel(list, "ros操作数据");
    }

    /**
     * 新增ros操作
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存ros操作
     */
    @RequiresPermissions("system:step:add")
    @Log(title = "ros操作", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RosStep rosStep)
    {
        return toAjax(rosStepService.insertRosStep(rosStep));
    }

    /**
     * 修改ros操作
     */
    @RequiresPermissions("system:step:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        RosStep rosStep = rosStepService.selectRosStepById(id);
        mmap.put("rosStep", rosStep);
        return prefix + "/edit";
    }

    /**
     * 修改保存ros操作
     */
    @RequiresPermissions("system:step:edit")
    @Log(title = "ros操作", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RosStep rosStep)
    {
        return toAjax(rosStepService.updateRosStep(rosStep));
    }

    /**
     * 删除ros操作
     */
    @RequiresPermissions("system:step:remove")
    @Log(title = "ros操作", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(rosStepService.deleteRosStepByIds(ids));
    }
}
